cmake_minimum_required( VERSION 2.8 )
project( Relocation_slam )

set( CMAKE_BUILD_TYPE "Release" )
set( CMAKE_CXX_FLAGS "-std=c++11 -O3" )

# 添加cmake模块以使用g2o
list( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules )

set(OpenCV_DIR /usr/local/opencv3/opencv3/share/OpenCV)
find_package( OpenCV 3.4 REQUIRED )
find_package( CSparse REQUIRED )
find_package( Eigen3 REQUIRED )
find_package( Ceres REQUIRED )
find_package( PCL REQUIRED )

set(CMAKE_MODULE_PATH /usr/local/lib/cmake/nlohmann_json)
find_package(nlohmann_json REQUIRED)

include_directories(
    ${PROJECT_SOURCE_DIR}
    ${PROJECT_SOURCE_DIR}/include
    ${CSPARSE_INCLUDE_DIR}
    ${Eigen3_INCLUDE_DIRS}
    ${CERES_INCLUDE_DIRS}
    ${PCL_INCLUDE_DIRS}
    "/usr/include/eigen3/"
)

add_library(${PROJECT_NAME} SHARED
    src/Frame.cc
    include/Kdtree_search.h
    include/ransac.h
    include/triangle.h
    include/pose_estimate_3d2d.h
    src/MapPoints.cpp
    include/mappoints_costFunction.h
    include/ceresBundle.h
    include/pcl_viewer.h
    src/pose_estimation_2d2d.cpp
        src/clearRobotDataTest.cpp)

target_link_libraries(${PROJECT_NAME}
    ${OpenCV_LIBS}
    ${Eigen3_LIBRARIES}
    ${CSPARSE_LIBRARY}
    ${CERES_LIBRARIES}
    ${PCL_LIBRARIES}
    ${PROJECT_SOURCE_DIR}/DBoW2/lib/libDBoW2.a
    g2o_core g2o_stuff g2o_types_sba g2o_csparse_extension)

#add_executable(relocation_slam src/main.cpp)
#target_link_libraries(relocation_slam ${PROJECT_NAME})
#
#add_executable(test src/test.cpp)
#target_link_libraries(test ${PROJECT_NAME})

add_executable(clearRobotDataTest src/clearRobotDataTest.cpp)
target_link_libraries(clearRobotDataTest ${PROJECT_NAME} ${nlohmann_json_LIBRARIES})

add_executable(turtlebotTest src/turtlebotTest.cpp)
target_link_libraries(turtlebotTest ${PROJECT_NAME} ${nlohmann_json_LIBRARIES})

